import Vue from 'vue';
import App from './App';
import router from './router';
import axios from 'axios';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-default/index.css';    // 默认主题
// import '../static/css/theme-green/index.css';       // 浅绿色主题
import "babel-polyfill";

Vue.use(ElementUI);
axios.defaults.headers.common['Authorization'] = localStorage.getItem('token');
axios.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    // 对响应错误做点什么
    if(typeof error.response!=='undefined'){
        if(error.response.statusText==='Unauthorized'){
            router.push('/login');
            return Promise.reject('登陆失效');
        }
    }

    return Promise.reject(error);
});
Vue.prototype.$axios = axios;

Vue.prototype.$baseUrl = 'http://gdj.com/admin';
new Vue({
    router,
    render: h => h(App),
}).$mount('#app');